<template>
  <div style="padding: 40px 10px">
    <el-form size="mini" label-width="80px" label-position="top">
      <el-row :gutter="10">
        <el-col :span="24">
          <el-form-item>
            <CtjGroup :name="'三国演示'" :tips="'中国古典文学四大名著之一'"></CtjGroup>
          </el-form-item>
        </el-col>
        <el-col :span="6">
          <el-form-item :label="'购买数据'">
            <el-input v-model="internal"></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="6">
          <el-form-item :label="'金额总计'">
            <CtjInputNumber v-model="value2" :precision="2" :prefix="'￥'" :suffix="'元'"> </CtjInputNumber>
          </el-form-item>
        </el-col>
        <el-col :span="24">
          <el-button type="primary" size="mini" @click="handleSub">提交</el-button>
        </el-col>
      </el-row>
    </el-form>
  </div>
</template>
<script>
export default {
  components: { money: () => import('./money.vue') },
  data() {
    return {
      moneyValue: 12345,
      value2: 254.56,
      time: '4:09:01',
      internal: 4
    };
  },
  methods: {
    handleSub() {
      // this.$message.info('提交到后台的数据：' + this.moneyValue);
      this.handleInternal();
    },
    handleInternal() {
      const me = this;
      if (this.internal) {
        clearInterval(this.internal);
      }
      this.internal = setInterval(function () {
        me.handleTime();
      }, 1000);
    },
    handleTime() {
      console.log('log内容');
      const date1 = '2022/04/03 00:00:00'; //开始时间
      const date2 = new Date(); //结束时间
      const date3 = date2.getTime() - new Date(date1).getTime(); //时间差的毫秒数

      //------------------------------

      //计算出相差天数
      const days = Math.floor(date3 / (24 * 3600 * 1000));

      //计算出小时数

      const leave1 = date3 % (24 * 3600 * 1000); //计算天数后剩余的毫秒数
      const hours = Math.floor(leave1 / (3600 * 1000));
      //计算相差分钟数
      const leave2 = leave1 % (3600 * 1000); //计算小时数后剩余的毫秒数
      const minutes = Math.floor(leave2 / (60 * 1000));
      //计算相差秒数
      const leave3 = leave2 % (60 * 1000); //计算分钟数后剩余的毫秒数
      const seconds = Math.round(leave3 / 1000);
      this.time = `${days}天 ${hours}小时:${minutes}分:${seconds}秒`;
      if (minutes > 15) {
        clearInterval(this.internal);
      }
    }
  }
};
</script>
<style lang="scss" scoped></style>
